<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>我的购物车</title>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript">
var currentPage=${currentPage};
var totalPage = ${totalPage};
function getList(){
	location.href="BuyerShopListServlet?currentPage="+currentPage;
}
function del(id){
	if(confirm("是否确定删除?")){
		location.href="BuyerShopDelServlet?id="+id;
	}
}
function clear2(){
	if(confirm("是否确定清空购物车?")){
		location.href="BuyerShopClearServlet";
	}
}
function order(sid,num,gid){
	location.href="BuyerOrderAddServlet?id="+gid+"&num="+num+"&sid="+sid;
}
function orderAll(){
	location.href="BuyerOrderAddAllServlet";
}
</script>
</head>
<body>
<jsp:include page="head.jsp"/>
<div id="container">
<table>
<tr>
<td align="left">
<input type="button" value="清空购物车" onclick="clear2();">
<input type="button" value="统一下单" onclick="orderAll();">
</td>
<td align="right">
<span id="tprice"></span>
</td>
</tr>
</table>
<table class="zebra" id="t">
<tr>
	<th>商品名称</th><th>价格</th><th>库存</th><th>店名</th><th>老板</th><th>联系方式</th><th>数量</th><th>总价</th><th>操作</th>
</tr>
<c:forEach items="${list}" var="s">
<tr>
	<td>${s.goods.goodsName }</td>
	<td>${s.goods.goodsPrice }</td>
	<td>${s.goods.goodsAccount }</td>
	<td>${s.goods.user.userShopname}</td>
	<td>${s.goods.user.userNickname}</td>
	<td>${s.goods.user.userPhone}</td>
	<td>${s.goodsNum}</td>
	<td>${s.goodsNum*s.goods.goodsPrice}</td>
	<td>
		<input type="button" value="删除" onclick="del(${s.shoppingcartId})">
		<input type="button" value="下单" onclick="order(${s.shoppingcartId},${s.goodsNum},${s.goods.goodsId})">
	</td>
</tr>
</c:forEach>
</table>
<jsp:include page="page.jsp"/>
<script type="text/javascript">
var table = document.getElementById("t");
var length = table.rows.length;
var totalprice = 0;
for(var i=1;i<length;i++){
	var tr = table.rows[i];
	var price = tr.cells[7].innerHTML;
	totalprice = totalprice+parseInt(price);
}
document.getElementById("tprice").innerHTML = "总价是："+totalprice;
</script>
</div>
</body>
</html>